#pragma once
#include <ctime>
#include <cstdlib>
#include <iostream>

using namespace std;

namespace SortTestHelper
{
	int* GenerateRandomArray(int n, int down, int up)
	{
		int* arr = new int[n];
		srand(time(NULL));

		for (int i = 0; i < n; ++i)
		{
			arr[i] = down + rand() % (up - down + 1);
		}
		return arr;
	}

	int* GenerateNearSortedArray(int n, int unsorted)
	{
		int* arr = new int[n];
		for (int i = 0; i < n; ++i)
		{
			arr[i] = i;
		}

		srand(time(NULL));
		for (int i = 0; i < unsorted; ++i)
		{
			int pos = rand() % n;
			swap(arr[pos], arr[n - pos]) ;
		}
		return arr;
	}

	int* CopyArray(int arr[], int n)
	{
		int* retArr = new int[n];

		memcpy(retArr, arr, n * sizeof(int));

		return retArr;
	}

	void ShowArray(int arr[], int n)
	{
		cout << "array : ";
		for (int i = 0; i < n; ++i)
		{
			cout << arr[i] << ", ";
		}
		cout << endl;
	}

	bool IsSorted(int arr[], int n)
	{
		for (int i = 0; i < n - 1; ++i)
		{
			if (arr[i] > arr[i + 1])
			{
				return false;
			}
		}
		return true;
	}
}